package thread;

/**
 * Created with IntelliJ IDEA.
 *
 * @ Title
 * @ Description:
 * @ Auther: 赵彦博
 * @ Date: 2023-01-05
 * @ Time: 9:26
 */
@SuppressWarnings({"all"})
class Singleton2 {
    private volatile static Singleton2 instance = null;

    private Singleton2() {
    }

    public static Singleton2 getInstance() {
        if (instance == null) {
            synchronized (Singleton2.class) {
                if (instance == null) {
                    instance = new Singleton2();
                }
            }
        }
        return instance;
    }
}

public class Demo2 {
    public static void main(String[] args) {
        Singleton2 instance = Singleton2.getInstance();
    }
}
